<script setup>
import { ref } from 'vue'
import axios  from 'axios'

defineProps({
  msg: String,
})
const fileList = ref([]);
const count = ref(0)
const handleFileUpload = (event)=>{
    const flie = event.target.files[0];
    // 在这里进行一系列的校验
    const formData = new FormData();
    formData.append("avatar",flie);
    axios.post('api/Upload/doUploadFile/test',formData,{
        'Content-type' : 'multipart/form-data'
    }).then(res=>{
        // 上传成功后的处理
    },err=>{
        // 出现错误时的处理
    })  
         
}
</script>

<template>
  <h1>{{ msg }}</h1>

  <div class="card">
    <button type="button" @click="count++">count is {{ count }}</button>
    <p>
      Edit
      <code>components/HelloWorld.vue</code> to test HMR
    </p>
  </div>

  <p>
    Check out
    <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
      >create-vue</a
    >, the official Vue + Vite starter
  </p>
  <p>
    Install
    <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
    in your IDE for a better DX
  </p>
  <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
  <input ref="fileUpload" type="file" @change="handleFileUpload">
  <a-upload
    v-model:file-list="fileList"
    name="avatar"
    action="api/Upload/doUploadFile/test"
  >
    <a-button>
      <upload-outlined></upload-outlined>
      Click to Upload
    </a-button>
  </a-upload>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
